package com.spring.bean.lazyloader;

import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.LazyLoader;

public class Student {

    private String name;

    private Score score;

    public  Student(){
        this.name = "张三";
        this.score = createScore();
    }

    public Score createScore(){
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(Score.class);
        return (Score) enhancer.create(Score.class, (LazyLoader)()->{
            System.out.println("lazyloader createScore.....");
            Score score = new Score();
            score.setScore(100);
            return score;
        });

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Score getScore() {
        return score;
    }

    public void setScore(Score score) {
        this.score = score;
    }
}
